{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 如果运行安装 pdf2docx 出现错误：No module named 'pywin32_bootstrap'\n",
    "# 删除下面的注释，运行安装 pywin32==225后，再运行安装 pdf2docx\n",
    "# !pip install pywin32==225"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Anaconda 默认不包含 pdf2docx，需要执行以下脚本进行安装\n",
    "# 如果运行安装出现错误：No module named 'pywin32_bootstrap'，则运行安装 pywin32==225（见上一步）\n",
    "!pip install -i https://mirrors.aliyun.com/pypi/simple/ pdf2docx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入工具包 Converter(PDF -> Word 转换器)\n",
    "from pdf2docx import Converter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# PDF文档文件路径（该文件必须存在）\n",
    "pdf_file = './files/PDF文档.pdf'\n",
    "# 转换后的 Word文档文件路径（文件不存在）\n",
    "word_file = './files/PDF转word文档.docx'\n",
    "\n",
    "# 构建一个PDF转Word的转换器，参数指定要转换的 PDF文档文件路径\n",
    "cv = Converter(pdf_file)\n",
    "# 转换为参数指定的 Word文档文件路径\n",
    "cv.convert(word_file)\n",
    "# 关闭转换器\n",
    "cv.close()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
